package com.timber.panels;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;

import pv.jfcx.JPVCurrency;

import com.timber.frame.ImsFrame;
import com.timber.util.Global;
import com.timber.util.SearchableComboBox;
import com.timber.util.TimberNameMgr;

public class Woodpanel {
	protected ImsFrame parent;
	protected GridBagLayout	 gridBagLayout=new GridBagLayout();
	protected JPanel			topPanel = new JPanel();
	protected JLabel ItemLabel; 
	protected JPVCurrency itemTF = new JPVCurrency();
	protected JLabel			timberNameLabel = new JLabel();
	protected SearchableComboBox		nameCB;
	protected SearchableComboBox		classCB;
	protected JLabel			classLabel = new JLabel();
	  protected TitledBorder		titledBorder;
	  
	  
	
	public Woodpanel(ImsFrame parent) {
		this.parent = parent;
		
		try {
			jbInit();
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
	
	void jbInit() throws Exception {
		topPanel.setLayout( gridBagLayout );
		topPanel.setMinimumSize(new Dimension(240, 150));
		topPanel.setPreferredSize(new Dimension(240, 150));
		titledBorder = new TitledBorder( BorderFactory.createEtchedBorder(), "" );
		ItemLabel  = new JLabel("Item Id");
		timberNameLabel.setText( "T name" );
		classLabel.setText( "T Class" );
		topPanel.setBorder( titledBorder );
		
		Dimension d = new Dimension(80,20);
		itemTF.setDecimals(0);
		itemTF.setSymbol("");
		itemTF.setText("");
		//itemTF.setEditable(false);			
		itemTF.setPreferredSize(d);
		itemTF.setMinimumSize(d);
		itemTF.setAlignment(2);
		itemTF.setForeground(Color.black);
		
		nameCB = new SearchableComboBox( Global.getMainFrame(),
				TimberNameMgr.mgr.getDataVector(),
				SearchableComboBox.INCLUDE_ALL,
				true );
		nameCB.setEditable( true );
		nameCB.setPreferredSize( new Dimension( 130, 21 ) );
		
		classCB = new SearchableComboBox( Global.getMainFrame(),
				TimberNameMgr.mgr.getDataVector(),
				SearchableComboBox.INCLUDE_ALL,
				true );
		classCB.setEditable( true );
		classCB.setPreferredSize( new Dimension( 130, 21 ) );
		
		
		
		
		topPanel.add( ItemLabel,
				new GridBagConstraints( 2,
						0,
						1,
						1,
						0.0,
						0.0,
						GridBagConstraints.SOUTHWEST,
						GridBagConstraints.NONE,
						new Insets( 10, 5, 0, 0 ), 0, 0 ) );
		topPanel.add( itemTF,
				new GridBagConstraints( 2,
						1,
						1,
						1,
						0.0,
						0.0,
						GridBagConstraints.NORTHWEST,
						GridBagConstraints.NONE,
						new Insets( 0, 5, 0, 0 ), 0, 0 ) );
		
		topPanel.add( timberNameLabel,
				new GridBagConstraints( 3,
						0,
						1,
						1,
						0.0,
						0.0,
						GridBagConstraints.SOUTHWEST,
						GridBagConstraints.NONE,
						new Insets( 10, 5, 0, 0 ), 0, 0 ) );
		topPanel.add( nameCB,
				new GridBagConstraints( 3,
						1,
						1,
						1,
						0.0,
						0.0,
						GridBagConstraints.NORTHWEST,
						GridBagConstraints.NONE,
						new Insets( 0, 5, 0, 0 ), 0, 0 ) );
		topPanel.add( classLabel,
				new GridBagConstraints( 4,
						0,
						1,
						1,
						0.0,
						0.0,
						GridBagConstraints.SOUTHWEST,
						GridBagConstraints.NONE,
						new Insets( 10, 15, 0, 0 ), 0, 0 ) );
		topPanel.add( classCB,
				new GridBagConstraints( 4,
						1,
						1,
						1,
						0.0,
						0.0,
						GridBagConstraints.NORTHWEST,
						GridBagConstraints.NONE,
						new Insets( 0, 15, 0, 0 ), 0, 0 ) );
		
		
	}
	
}
